package com.tangruojie.controller;

import com.tangruojie.domain.Book;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/books") // 模块名
public class BookController {

    @PostMapping
    public String save(@RequestBody Book book) {
        System.out.println("book save..." + book);
        return "{'module':'book save success'}";
    }

    @GetMapping
    public List<Book> getAll() {
        System.out.println("book getAll...");
        List<Book> list = new ArrayList<>();
        list.add(new Book(1, "Spring", "Spring", "Spring"));
        list.add(new Book(2, "SpringMVC", "SpringMVC", "SpringMVC"));
        list.add(new Book(3, "SpringBoot", "SpringBoot", "SpringBoot"));
        return list;
    }

}
